<template>
  <!--登录配置项编辑-->
  <view class="LoginConfigPopup">
    <u-popup :show="isPopup" :round="15" mode="bottom" @close="onClose" safe-area-inset-bottom>
      <view class="title">编辑详情</view>
      <view class="operate">
        <view class="item" @click="edit">编辑</view>
        <view class="item" @click="moveUp">上移</view>
        <view class="item" @click="moveDown">下移</view>
        <view class="item" :class="{disabled: item.disable}" @click="remove">删除</view>
        <view class="item flex flex-row between item-center switch">
          <view class="">是否必填</view>
          <u-switch activeColor="#37B874" inactiveColor="#D9D9D9" v-model="switchFl" size="22"
                    :disabled="item.disable"  @change="change"></u-switch>
        </view>
      </view>
      <view class="footer">
        <view class="line"></view>
        <view class="close btn" @click="onClose">取消</view>
      </view>
    </u-popup>
  </view>
</template>
<script>
export default {
  name: "LoginConfigPopup",
  data() {
    return {
      isPopup: false,
      switchFl: true,
      label: "",
      text: "",
      item: {}
    }
  },
  methods: {
    onClose() {
      this.isPopup = false;
      this.$emit("close")
    },
    async open(item) {
      this.item = item;
      this.isPopup = true;
    },
    edit(){
      this.$emit("edit", this.item.label);
    },
    remove() {
      if (this.item.disable) {
        return;
      }
      this.$emit("remove", this.item.label);
      this.isPopup = false;
    },
    moveUp() {
      this.$emit("moveUp", this.item.label);
      this.isPopup = false;
    },
    moveDown() {
      this.$emit("moveDown", this.item.label);
      this.isPopup = false;
    },
    change(){
      this.$emit("switchChange", {label:this.item.label,switchFl:this.switchFl});
      this.isPopup = false;
    }

  }
}
</script>
<style scoped lang="scss">
.LoginConfigPopup {

  .title {
    color: #333333;
    font-size: 32rpx;
    font-weight: bold;
    text-align: center;
    height: 75px;
    line-height: 75px;
    border-bottom: 1px solid #EEEEEE;
  }

  .operate {
    .item {
      height: 60px;
      text-align: center;
      line-height: 60px;
      border-bottom: 1px solid #EEEEEE;
      font-size: 14px;
      color: #000000;

      &.disabled {
        background-color: #F2F2F2;
      }
    }

    .switch {
      padding: 0 22px 0 32px;
    }
  }

  .btn {
    height: 74px;
    text-align: center;
    line-height: 74px;
    color: #000000;
    font-size: 14px;
  }

  .line {
    width: 100%;
    background-color: #F2F2F2;
    height: 6rpx;
  }
}
</style>